 /****** Object:  Stored Procedure DeliveredOrdersGetList    Script Date: Tuesday, July 18, 2006 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spDeliveredOrdersGetListByProductCode]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [spDeliveredOrdersGetListByProductCode]
GO

	
CREATE PROCEDURE spDeliveredOrdersGetListByProductCode
	@ProductCode varchar(5),
	@SupplierCode varchar(3),
	@Owner int
AS

SELECT
	[DeliveredOrders].[DeliveredOrderID],
	Offices.[OfficeID],
	Offices.OfficeName as OfficeName,
	[SupplierCode],
	[OrderNo],
	[YY],
	[OrderDate],
	[QtyIssued],
	[DateIssued],
	[ProductCode],
	[BulkOrderID],
	[CustomerName],
	[POID]
FROM
	[DeliveredOrders] LEFT JOIN Offices ON [DeliveredOrders].[OfficeID] = Offices.[OfficeID]
WHERE [ProductCode]= @ProductCode
AND SupplierCode=@SupplierCode
AND [DeliveredOrders].OfficeID = @Owner
ORDER BY [OrderDate] DESC

GO

	
